package com.tpshion.deploy.task.support;

import com.tpshion.deploy.common.support.BusinessException;
import com.tpshion.deploy.task.AbstartTaskHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
public class TaskFactory {

    @Autowired
    private List<AbstartTaskHandler> taskHandlerList;

    public AbstartTaskHandler getTaskHandler(String type){
        for (AbstartTaskHandler taskHandler : taskHandlerList) {
            if(taskHandler.getType().equals(type)){
                return taskHandler;
            }
        }
        throw new BusinessException("找不到任务处理器");
    }
}
